//
//  ViewController.swift
//  Guess
//
//  Created by stu on 2019/9/10.
//  Copyright © 2019年 wenliang. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var doraguess: UIImageView!
    @IBOutlet weak var meguess: UIImageView!
    @IBAction func guess(_ sender: Any) {
        doraguess.image = UIImage(named:"rock")
        
        let guess = arc4random_uniform(3)
        var result = ""
        if guess==0 {
            meguess.image=UIImage(named:"scissor")
            result = "you loss"
        }else if 1==guess{
            meguess.image=UIImage(named:"rock")
            result = "平手"
        }else {
            meguess.image=UIImage(named:"paper")
            result = "you win"
        }
        let alter = UIAlertController(title: "游戏结果", message: result, preferredStyle: .alert)
        alter.addAction(UIAlertAction(title: "确定", style: .default, handler: { _ in
            self.doraguess.image=nil
            self.meguess.image=nil
        }
            )
        )
        present(alter, animated: true, completion: nil)
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

